﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace LWH.ByteProtocol
{
    /// <summary>
    /// 包装模式基础类
    /// </summary>
    public class WrapperAbstractProperty : AbstractProperty
    {
        /// <summary>
        /// 被包装属性
        /// </summary>
        protected AbstractProperty mWrappedProperty;


        public WrapperAbstractProperty(AbstractProperty wrappedProperty)
        {
            setWrappedProperty(wrappedProperty);
        }

        public AbstractProperty getWrappedProperty()
        {
            return mWrappedProperty;
        }

        protected void setWrappedProperty(AbstractProperty wrappedProperty)
        {
            mWrappedProperty = wrappedProperty;
        }


        #region Override AbstractProperty Method


        protected internal override void setIndex(int index)
        {
            mWrappedProperty.setIndex(index);
        }


        public override int getIndex()
        {
            return mWrappedProperty.getIndex();
        }


        protected internal override OwnerProperty getOwnerProperty()
        {
            return mWrappedProperty.getOwnerProperty();
        }


        protected internal override int getOwnerOffset()
        {
            return mWrappedProperty.getOwnerOffset();
        }


        protected internal override byte[] getSrcData()
        {
            return mWrappedProperty.getSrcData();
        }

        #endregion

        #region Override IProperty Method


        public override int getLength()
        {
            return mWrappedProperty.getLength();
        }


        public override int getOffset()
        {
            return mWrappedProperty.getOffset();
        }


        public override byte[] getData()
        {
            return mWrappedProperty.getData();
        }


        public override void setData(byte[] data, int offset, int length)
        {
            mWrappedProperty.setData(data, offset, length);
        }



        public override bool handleProperty(Dictionary<String, Object> context)
        {
            return mWrappedProperty.handleProperty(context);
        }

        #endregion
    }
}
